The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section. Similarly, the problems identified with an approach should not be assumed to have been recognized in the prior art, unless otherwise indicated.
For convenience of expression, various entities that represent sets of instructions (e.g. functions, queries) are described as performing actions, when in fact, a computer, process, database server, or other executing entity performs those actions in response to executing or interpreting the set of instructions. For example, a function may be described as determining that a condition exists or a query may be described as accessing information. These are just convenient ways of expressing that a computer, process, database server or other executing entity is determining that a condition exists in response to executing a function or is accessing data in response to executing or computing a query.
A Database Management System (DBMS) stores data in a database in one or more data containers, each container contains records, and the data within each record is organized into one or more fields. In a DBMS that stores data in a relational database, the data containers are referred to as tables, the records are referred to as rows, and the attributes are referred to as columns. In object oriented databases, the data containers are referred to as object classes, the records are referred to as objects, and the attributes are referred to as object attributes. Other database architectures may use other terminology.
The DBMS retrieves and manipulates data in response to receiving a database statement. Typically, the database statement conforms to a database language (or query language), such as Structured Query Language (SQL). A database statement can specify a query operation, a data manipulation operation, or a combination thereof. A database statement that specifies a query operation is referred to herein as a query. The present invention is not limited to database statements that specify a particular type of operation. However, for the purpose of explanation, embodiments of the present invention are illustrated using queries.
Typically, changes to database systems are made using transaction processing. A transaction is a set of operations that change data. In a DBMS, the operations are specified by one or more database commands. Two types of transaction are read-only transaction and read-write transactions. Read-only transactions read data and may copy the data read to another location, without modifying the original data or the location of the original data. Read-write transactions may read or modify data. Committing a transaction refers to making the changes for a transaction permanent. For example, if a read-only transaction copies data, the read-only transaction commits once the copy of the data being read is complete and permanent. Under transaction processing, all the changes for a transaction are made atomically. When a transaction is committed, either all changes are committed, or the transaction is rolled back.
In transaction processing, changes to a database are applied as transactions in a way that preserves four properties. These properties are referred to as ACID properties. ACID is an acronym for Atomicity, Consistency, Isolation, and Durability. The ACID properties are defined as follows.
Atomicity: A transaction should be done or undone completely and unambiguously.
Consistency: A transaction should preserve invariant properties (such as integrity constraints) defined on the data. On completion of a successful transaction, the data should evolve from one consistency state to another.
Isolation: Each transaction should appear to execute independently of other transactions that may be executing concurrently in the same environment. The effect of executing a set of transactions serially should be the same as that of running them concurrently. This requires during the course of a transaction, that intermediate (possibly inconsistent) states of the data should not be exposed to any other transactions. Consequently, transactions must not be able to see the changes made by concurrently executing transactions until those transactions have been completed as an atomic unit and made persistent, i.e. committed.
Durability: The effects of a completed transaction should always be persistent.
In order to provide ACID consistent database views for a read-only transaction, copies of database rows (and index nodes) are captured and stored on disk by read-write transactions prior to modification, which are referred to as pre-modification copies. Specifically, a pre-modification copy of a row is a copy of the row made by a transaction or process prior to modifying (e.g., inserting, changing, or deleting) the row; the copy is referred to herein as snapshots or snapshot records. These snapshots of the rows are accessed by read-only transactions. In this fashion, declared read-only transactions (that can never modify the database) do not need to lock or otherwise restrict declared read-write transactions that modify the database and coordinate access with other read-write transactions with various levels of locks on rows and index nodes.
The snapshot copies of the database rows are stored in snapshot pages of a snapshot shot storage area on disk. The snapshot pages are chained from one to the next. Each snapshot page can hold one or more snapshots from different rows from the same live database page. Slower non-volatile memory (e.g., a disk) is used for the snapshot storage rather than faster volatile memory, because the amount storage space needed for the snapshot storage can exceed the amount of volatile memory available on many computer systems. However, because a snapshot can be accessed far more quickly and efficiently if it were stored in volatile memory, a mechanism that permits this is highly desirable.